---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: {{ openshift_cluster_autoscaler_name }}
  name: {{ openshift_cluster_autoscaler_name }}
  namespace: {{ openshift_cluster_autoscaler_namespace }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ openshift_cluster_autoscaler_name }}
      role: infra
  template:
    metadata:
      labels:
        app: {{ openshift_cluster_autoscaler_name }}
        role: infra
    spec:
      containers:
      - args:
        - --alsologtostderr
        - --v={{ openshift_cluster_autoscaler_version }}
        - --skip-nodes-with-local-storage={{ openshift_cluster_autoscaler_skip_nodes_local_storage }}
        - --leader-elect-resource-lock=configmaps
        - --namespace={{ openshift_cluster_autoscaler_namespace }}
{% if openshift_cluster_autoscaler_scale_down_delay is defined %}
        - --scale-down-delay={{ openshift_cluster_autoscaler_scale_down_delay }}
{% endif %}
        - --cloud-provider={{ openshift_cluster_autoscaler_cloud_provider }}
{% for group in openshift_cluster_autoscaler_node_groups %}
        - --nodes={{ group.min }}:{{ group.max }}:{{ group.name }}
{% endfor %}
{% if openshift_cluster_autoscaler_cloud_provider == 'aws' %}
        env: {{ openshift_cluster_autoscaler_aws_env_vars | union(openshift_cluster_autoscaler_env_vars) | to_json }}
{% else %}
        env: {{ openshift_cluster_autoscaler_env_vars }}
{% endif %}
        image: {{ openshift_cluster_autoscaler_image }}
        name: autoscaler
{% if openshift_cluster_autoscaler_cloud_provider == 'aws' %}
        volumeMounts:
        - mountPath: {{ openshift_cluster_autoscaler_aws_creds_path | dirname }}
          name: {{ openshift_cluster_autoscaler_aws_creds_name }}
          readOnly: true
{% endif %}
      nodeSelector: {{ openshift_cluster_autoscaler_node_selector | to_json }}
      dnsPolicy: ClusterFirst
      serviceAccountName: {{ openshift_cluster_autoscaler_serviceaccount }}
      terminationGracePeriodSeconds: 30
{% if openshift_cluster_autoscaler_cloud_provider == 'aws' %}
      volumes:
      - name: {{ openshift_cluster_autoscaler_aws_creds_name }}
        secret:
          defaultMode: 420
          secretName: {{ openshift_cluster_autoscaler_aws_secret_name }}
{% endif %}
